import request from '@/utils/request'


//查询接收站
export function getReceiveStationInfo() {
  return request({
    url: '/system/receivestation/getReceiveStationInfo',
    method: 'get',
  })
}

// 获取监测站和卫星位置接口
// * @param monitroArea 监测区域经纬度范围
// * @param stationDistState 监测站分布方式，1-格网部署，2-随机部署；3-位置导入
// * @param stationInterStr 监测站间隔(1-格网部署时有效)
// * @param monitorStationData 监测站数据
export async function receiverSim(monitroArea, stationDistState, stationInterStr, stationNumStr, monitorStationData) {
  return await request({
    url: '/system/receivestation/receiverSim',
    method: 'get',
    params: {
      monitroArea,
      stationDistState,
      stationInterStr,
      stationNumStr,
      monitorStationData
    }
  })
}

//查询干扰源
export function getInterferenceDataList() {
  return request({
    url: '/system/interference/getInterferenceDataList',
    method: 'get',
  })
}
// * V2-2：获取干扰源位置接口
// * @param monitorArea 监测区域经纬度范围
// * @param interferenceDistState 干扰源分布方式，0-位置导入，1-随机部署
// * @param interferencePos 干扰源经纬度坐标(0-位置导入时有效)
// * @param interferenceNum 干扰源数量(1-随机部署时有效)
// * @param interferenceSourcePower 各干扰源发射功率
// * @param interferenceType 各干扰源类型（1-单音，2-多音，3-线性扫频，4-脉冲）
// * @return
export async function interferenceSim(monitorArea, interferenceDistState, interferencePos, interferenceNum, interferenceSourcePower, interferenceType) {
  return await request({
    url: '/system/receivestation/interferenceSim',
    method: 'get',
    params: {
      monitorArea,
      interferenceDistState,
      interferencePos,
      interferenceNum,
      interferenceSourcePower,
      interferenceType
    }
  })
}

//查询障碍物
export function getObstacleDataList() {
  return request({
    url: '/system/obstacle/getObstacleDataList',
    method: 'get',
  })
}

//模拟计算
export function getInterferenceLoc(monitroArea, interferenceDisState, interferenceNum, interferenceData, receiveStationData) {
  return request({
    url: '/system/receivestation/calcInterferenceLocation',
    method: 'get',
    params: {
      monitroArea,
      interferenceDisState,
      interferenceNum,
      interferenceData,
      receiveStationData
    }
  });
}

// 载噪比
export function signalSim(receiverPos, satellitePos, interferencePos, interferenceNum, interferenceSourcePower, interferenceType, simTime) {
  return request({
    url: '/system/receivestation/signalSim',
    method: 'get',
    params: {
      receiverPos,
      satellitePos,
      interferencePos,
      interferenceNum,
      interferenceSourcePower,
      interferenceType,
      simTime
    }
  });
}

// 定位误差计算接口
export function calculateLocationError(interferencePostion, interferencePostionDetected) {
  return request({
    url: '/system/receivestation/calculateLocationError',
    method: 'get',
    params: {
      interferencePostion,
      interferencePostionDetected
    }
  });
}

export function interferenceLocationLatlon(stationPos, stationCNRT) {
  return request({
    url: '/system/receivestation/interferenceLocationLatlon',
    method: 'get',
    params: {
      stationPos,  stationCNRT
    }
  });
}

export function interferenceAnalyzeStatic(receiverPos, satellitePos, interferencePos, interferenceNum, interferenceSourcePower, interferenceType, simTime) {
  return request({
    url: '/system/receivestation/interferenceAnalyzeStatic',
    method: 'get',
    params: {
      receiverPos, satellitePos, interferencePos, interferenceNum, interferenceSourcePower, interferenceType, simTime
    }
  });
}

// 结果入库
export function saveJszAnalyseData(name, result) {
  return request({
    url: '/system/receivestation/saveJszAnalyseData',
    method: 'post',
    headers: {
      'Content-Type': 'application/json'
    },
    data: {
      name: name,
      result: JSON.stringify(result)
    }
  });
}

// 获取历史数据
export function queryJszLastRecord(lastCount) {
  return request({
    url: '/system/receivestation/queryJszLastRecord',
    method: 'get',
    params: {
      lastCount
    }
  });
}

// 根据id获取历史数据
export function getJszRecordById(id) {
  return request({
    url: '/system/receivestation/getJszRecordById',
    method: 'get',
    params: {
      id
    }
  });
}

//////  ads-b
// 干扰源生成模式（自动生成）
export function dataProcess1(interferenceNum, range, areaNum, startTime,endTime) {
  return request({
    url: '/system/adsb/dataProcess1',
    method: 'get',
    params: {
      interferenceNum, range, areaNum, startTime,endTime
      }
    });
  }

// 干扰源生成模式（手动生成）
export function dataProcess2(areaNum, startTime,endTime, interferenceNum, locationReal,range) {
  return request({
    url: '/system/adsb/dataProcess2',
    method: 'get',
    params: {
      areaNum, startTime,endTime, interferenceNum, locationReal,range
      }
    });
  }

// 干扰检测，获取矩阵
export function fun1(areaNum, gridStep) {
  return request({
    url: '/system/adsb/fun1',
    method: 'get',
    params: {
      areaNum,  gridStep
      }
    });
  }

// 干扰定位
export function fun2(areaNum) {
  return request({
    url: '/system/adsb/fun2',
    method: 'get',
    params: {
      areaNum
      }
    });
  }

// 干扰检测，获取矩阵; 干扰定位
  export function fun(areaNum, gridStep) {
    return request({
      url: '/system/adsb/fun',
      method: 'get',
      params: {
        areaNum, gridStep
        }
      });
    }

// adsb获取定位
export function getAdsbLoc(lon1, lat1, lon2, lat2, gridLength) {
  return request({
    url: 'system/adsb/callFun2',
    method: 'get',
    params: {
       lon1,  lat1,  lon2,  lat2,  gridLength
      }
    });
  }

// 结果入库
export function startCalculLocatAndDetectApi(params, taskName,  areaNum, gridStep, timeStamp) {
  return request({
    url: '/system/adsb/startCalculLocatAndDetect',
    method: 'post',
    headers: {
      'Content-Type': 'application/json'
    },
    data: {
      paramsData: JSON.stringify(params), 
      name: taskName,
      areaNum: areaNum,
      gridStep: gridStep,
      timeStamp: timeStamp
    }
  });
}

// 获取历史数据
export function queryAdsbLastRecordList(lastCount) {
  return request({
    url: '/system/adsb/queryAdsbLastRecord',
    method: 'get',
    params: {
      lastCount
    }
  });
}